package com.cx.mall.seckill.controller;

import com.cx.mall.common.entity.seckill.entity.SeckillGoods;
import com.cx.mall.common.util.ResponseVo;
import com.cx.mall.seckill.service.ISeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zs
 * @since 2025-08-07
 */
@RestController
@RequestMapping("/seckill/goods")
public class SeckillGoodsController {

    @Autowired
    private ISeckillGoodsService seckillGoodsService;

    @GetMapping("/activity/{activityId}")
    public ResponseVo listByActivityById(@PathVariable("activityId") Integer activityId){

        List<SeckillGoods> list = seckillGoodsService.listByActivityById(activityId);
        if(list.isEmpty()){
            return ResponseVo.success(null);
        }
        return ResponseVo.success(list);
    }
}
